﻿using System;
using Netbits.Common.Collections;

namespace Netbits.Common.Logging
{
	/// <summary>
	/// Represents a simple static Log class for simple logging
	/// </summary>
	public static class Log
	{
		#region Private Variables

		static LogManager _Manager = new LogManager();
		static LogGroup _DefaultGroup = _Manager.GetDefaultGroup();

		#endregion

		#region Public Properties

		/// <summary>
		/// Returns the static instance of LogManager 
		/// </summary>
		public static LogManager Manager
		{
			get
			{
				return _Manager;
			}
		}

		/// <summary>
		/// Returns an enumerable list of all logs
		/// </summary>
		public static IExtended<ListExtended<LogEntry>, LogEntry> Logs
		{
			get
			{
				return _Manager.Logs;
			}
		}

		/// <summary>
		/// Get or set the maximum cached log-items.
		/// -1 for unlimited cache.
		/// default is 1000 items.
		/// </summary>
		public static int MaxCache
		{
			get
			{
				return _Manager.MaxCache;
			}
			set
			{
				_Manager.MaxCache = value;
			}
		}

		/// <summary>
		/// Get or sets indicating whether logging is enabled for <c>Info</c> level on default-group
		/// </summary>
		public static bool IsInfoEnabled
		{
			get
			{
				return _DefaultGroup.IsInfoEnabled;
			}
			set
			{
				_DefaultGroup.IsInfoEnabled = value;
			}
		}

		/// <summary>
		/// Get or sets indicating whether logging is enabled for <c>Warning</c> level on default-group
		/// </summary>
		public static bool IsWarningEnabled
		{
			get
			{
				return _DefaultGroup.IsWarningEnabled;
			}
			set
			{
				_DefaultGroup.IsWarningEnabled = value;
			}
		}

		/// <summary>
		/// Get or sets indicating whether logging is enabled for <c>Error</c> level on default-group
		/// </summary>
		public static bool IsErrorEnabled
		{
			get
			{
				return _DefaultGroup.IsErrorEnabled;
			}
			set
			{
				_DefaultGroup.IsErrorEnabled = value;
			}
		}

		/// <summary>
		/// Get or sets indicating whether logging is enabled for <c>Fatal</c> level on default-group
		/// </summary>
		public static bool IsFatalEnabled
		{
			get
			{
				return _DefaultGroup.IsFatalEnabled;
			}
			set
			{
				_DefaultGroup.IsFatalEnabled = value;
			}
		}

		/// <summary>
		/// Get or sets indicating whether logging is enabled for <c>Debug</c> level on default-group
		/// </summary>
		public static bool IsDebugEnabled
		{
			get
			{
				return _DefaultGroup.IsDebugEnabled;
			}
			set
			{
				_DefaultGroup.IsDebugEnabled = value;
			}
		}

		#endregion

		#region Public Functions

		/// <summary>
		/// Write the message at the <c>Info</c> level on default-group
		/// </summary>
		/// <param name="Message_">Message to write.</param>
		public static void Info( string Message_ )
		{
			_DefaultGroup.Info( Message_ );
		}

		/// <summary>
		/// Write the message at the <c>Info</c> level with specified formating items on default-group
		/// </summary>
		/// <param name="Message_">A string message containing format items.</param>
		/// <param name="Parameters_">Parameters to format</param>
		public static void Info( string Message_, params object[] Parameters_ )
		{
			_DefaultGroup.Info( Message_, Parameters_ );
		}

		/// <summary>
		/// Write the message at the <c>Info</c> level with specified exception on default-group
		/// </summary>
		/// <param name="Message_">An exception to be logged</param>
		public static void Info( Exception Message_ )
		{
			_DefaultGroup.Info( Message_ );
		}

		/// <summary>
		/// Write the message at the <c>Warning</c> level on default-group
		/// </summary>
		/// <param name="Message_">Message to write</param>
		public static void Warning( string Message_ )
		{
			_DefaultGroup.Warning( Message_ );
		}

		/// <summary>
		/// Write the message at the <c>Warning</c> level with specified formating items on default-group
		/// </summary>
		/// <param name="Message_">A string message containing format items</param>
		/// <param name="Parameters_">Parameters to format</param>
		public static void Warning( string Message_, params object[] Parameters_ )
		{
			_DefaultGroup.Warning( Message_, Parameters_ );
		}

		/// <summary>
		/// Write the message at the <c>Warning</c> level with specified exception on default-group
		/// </summary>
		/// <param name="Message_">An exception to be logged</param>
		public static void Warning( Exception Message_ )
		{
			_DefaultGroup.Warning( Message_ );
		}

		/// <summary>
		/// Write the message at the <c>Error</c> level on default-group
		/// </summary>
		/// <param name="Message_">Message to write</param>
		public static void Error( string Message_ )
		{
			_DefaultGroup.Error( Message_ );
		}

		/// <summary>
		/// Write the message at the <c>Error</c> level with specified formating items on default-group
		/// </summary>
		/// <param name="Message_">A string message containing format items</param>
		/// <param name="Parameters_">Parameters to format</param>
		public static void Error( string Message_, params object[] Parameters_ )
		{
			_DefaultGroup.Error( Message_, Parameters_ );
		}

		/// <summary>
		/// Write the message at the <c>Error</c> level with specified exception on default-group
		/// </summary>
		/// <param name="Message_">An exception to be logged</param>
		public static void Error( Exception Message_ )
		{
			_DefaultGroup.Error( Message_ );
		}

		/// <summary>
		/// Write the message at the <c>Fatal</c> level on default-group
		/// </summary>
		/// <param name="Message_">Message to write</param>
		public static void Fatal( string Message_ )
		{
			_DefaultGroup.Fatal( Message_ );
		}

		/// <summary>
		/// Write the message at the <c>Fatal</c> level with specified formating items on default-group
		/// </summary>
		/// <param name="Message_">A string message containing format items</param>
		/// <param name="Parameters_">Parameters to format</param>
		public static void Fatal( string Message_, params object[] Parameters_ )
		{
			_DefaultGroup.Fatal( Message_, Parameters_ );
		}

		/// <summary>
		/// Write the message at the <c>Fatal</c> level with specified exception on default-group
		/// </summary>
		/// <param name="Message_">An exception to be logged</param>
		public static void Fatal( Exception Message_ )
		{
			_DefaultGroup.Fatal( Message_ );
		}

		/// <summary>
		/// Write the message at the <c>Debug</c> level on default-group
		/// </summary>
		/// <param name="Message_">Message to write</param>
		public static void Debug( string Message_ )
		{
			_DefaultGroup.Debug( Message_ );
		}

		/// <summary>
		/// Write the message at the <c>Debug</c> level with specified formating items on default-group
		/// </summary>
		/// <param name="Message_">A string message containing format items</param>
		/// <param name="Parameters_">Parameters to format</param>
		public static void Debug( string Message_, params object[] Parameters_ )
		{
			_DefaultGroup.Debug( Message_, Parameters_ );
		}

		/// <summary>
		/// Write the message at the <c>Debug</c> level with specified exception on default-group
		/// </summary>
		/// <param name="Message_">An exception to be logged</param>
		public static void Debug( Exception Message_ )
		{
			_DefaultGroup.Debug( Message_ );
		}

		#endregion
	}
}
